#coding=utf-8

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.views.generic import list_detail
import settings
import os
from mediacom.bgcms.models import News

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

news_detail = {
    'queryset': News.objects.all(),
    'template_name':'news_detail.html',
}

notify_list = {
    'queryset': News.objects.filter(is_notify__exact=True).order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'中培公告'},
}

health_spread_list = {
    'queryset': News.objects.filter(news_type__type__exact='健康文化传播与推广').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'健康文化传播与推广'},
}

health_product_list = {
    'queryset': News.objects.filter(news_type__type__exact='健康文化产品推广').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'健康文化产品推广'},
}

sport_spread_list = {
    'queryset': News.objects.filter(news_type__type__exact='体育文化传播与推广').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'体育文化传播与推广'},
}

sport_product_list = {
    'queryset': News.objects.filter(news_type__type__exact='体育文化产品推广').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'体育文化产品推广'},
}

tests_list = {
    'queryset': News.objects.filter(news_type__type__exact='模拟试题').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'模拟试题'},
}

courses_list = {
    'queryset': News.objects.filter(news_type__type__exact='热点课程').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'热点课程'},
}

industry_list = {
    'queryset': News.objects.filter(news_type__type__exact='行业动态').order_by('-pub_date'),
    'template_name':'news_list.html',
    'paginate_by':10,
    'extra_context':{'news_type':'行业动态'},
}

urlpatterns = patterns('',
    # Example:
    # (r'^mediacom/', include('mediacom.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/(.*)', admin.site.root),
    
    (r'^tiny_mce/(?P<path>.*)$','django.views.static.serve',{'document_root': os.path.join(settings.STATIC_PATH,'js/tiny_mce')}),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_PATH}),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
    (r'^mymedia/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),

    #(r'^$','django.views.generic.simple.redirect_to',{'url':'/welcome/'}),
    (r'^$',direct_to_template, {'template':'FlashIndex.html'}),
    #(r'^welcome/$', direct_to_template, {'template':'index.html'}),
    (r'^welcome/$', 'mediacom.bgcms.views.index'),
    (r'^photos/$', 'mediacom.bgcms.views.show_album'),
    (r'^photos/album/(?P<id>\d+)$', 'mediacom.bgcms.views.show_photos'),
    (r'^guestbook/$', 'mediacom.bgcms.views.guestbook_add'),
    (r'^signup/$', 'mediacom.bgcms.views.signup_add'),
    (r'^news/detail/(?P<object_id>\d+)/$', list_detail.object_detail, news_detail),
    
    (r'^health/spread/$',list_detail.object_list, health_spread_list),
    (r'^health/product/$', list_detail.object_list, health_product_list),
    (r'^sport/spread/$', list_detail.object_list, sport_spread_list),
    (r'^sport/product/$',list_detail.object_list, sport_product_list),
    (r'^notify/$',list_detail.object_list, notify_list),
    
    (r'^edu/$', direct_to_template, {'template':'edu.html'}),
    (r'^career/$', direct_to_template, {'template':'career.html'}),
    (r'^health/$', direct_to_template, {'template':'health.html'}),
    (r'^sport/$', direct_to_template, {'template':'sport.html'}),
    (r'^tests/$',list_detail.object_list, tests_list),
    (r'^courses/$',list_detail.object_list, courses_list),
    (r'^industry/$',list_detail.object_list, industry_list),
    (r'', include('django.contrib.flatpages.urls')),
)
